import { selectPatientInfo, selectMonitorrecord } from "@/api/print";
import { formatDate } from "@/utils/index.js";

let indexMiXin = {
  data() {
    return {
      userInfo: {
        bedCode: "",
        patientName: "",
        sex: "",
        age: "",
        weight: "",
        mrn: "",
        departmentName: "",
        diagnosis: "",
        accessTime: "",
        leaveTime: "",
        anesthetist: "",
      },
    };
  },
  methods: {
    getUseINfo() {
      return new Promise((resolve) => {
        selectPatientInfo().then((res) => {
          if (res.code == 200 && res.data) {
            this.userInfo = res.data;
          }
          resolve();
        });
      });
    },
    /**
     * 获取列表数据
     */
    getList(params) {
      return new Promise((resolve) => {
        selectMonitorrecord(params).then((res) => {
          if (res.code == 200 && res.data) {
            resolve(res.data);
          } else {
            resolve();
          }
        });
      });
    },
    /**
     * 处理后台接口返回的时间
     */
    setHour(list, title) {
      list.forEach((item) => {
        item.getHours = formatDate(item[title], 2);
        if (item.nursingRecord) {
          item.nursingRecordList = this.scliceStr(item.nursingRecord);
        }
      });
      return list;
    },
  },
};
export default indexMiXin;
